﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@using GoodMan.Infrastructure.Entities.Contract;
@using GoodMan.Tool.Framework;
@{
    ViewBag.Title = "楼栋排班";
    Layout = "~/Areas/WorkSpace/Views/Shared/_StaffTemplete.cshtml";
    ItemListBox<Duty> dutyList = ViewBag.MyDuty;
}
<link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        我的排班</h1>
</div>
<div id="breadcrumb">
    <a href="/workspace/staff/index" title="Go to Home" class="tip-bottom"><i class="icon-home">
    </i>首页</a> <a href="/workspace/Staff/myduty" class="tip-bottom">我的排班</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <h5>
                        我的排班</h5>
                </div>
                <div class="widget-content nopadding">
                    <table class="table table-bordered data-table">
                        <thead>
                            <tr>
                                <th width="20%">
                                    日期
                                </th>
                                <th width="15%">
                                    楼栋
                                </th>
                                <th>
                                    排班
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                var my = new User().Find(HttpContext.Current.User.Identity.Name);
                                if (dutyList != null && dutyList.Data != null && dutyList.Data.Any())
                                {
                                    foreach (var item in dutyList.Data)
                                    {
                                        var dormitory = new Dormitory().Find(my.FloorId.ToString());
                                        if(dormitory == null)
                                        {
                                            continue;
                                        }
                                        DutySet data = item.Content.ToObject<DutySet>();
                                        DormitoryDuty myduty = data.duty.FirstOrDefault(c => c.Dormitory == my.FloorId);
                                <tr class="gradeX">
                                    <td>
                                        @item.Date
                                    </td>
                                    <td>
                                        @dormitory.Name
                                    </td>
                                    <td>
                                        @if (myduty != null)
                                        {
                                            var userList = myduty.userList;
                                            <span>早班：@(userList.first != null ? userList.first.Realname : "未设定") &nbsp;&nbsp;</span> 
                                            <span>中班：@(userList.middle != null ? userList.middle.Realname : "未设定") &nbsp;&nbsp;</span> 
                                            <span>晚班：@(userList.last != null ? userList.last.Realname : "未设定")</span> 
                                        }
                                        else
                                        {
                                            <b>暂无数据</b>
                                        }
                                    </td>
                                </tr>
                                    }
                                }
                      
                            }
                        </tbody>
                    </table>
                </div>
                @Html.Raw(dutyList.PageItemSegment)
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>
    <script type="text/javascript" src="/Scripts/messages_cn.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likSelf').addClass('open');

            $('#likSelf').addClass('active');
            $('#status').each(function () {
                $(this).select2();
            });
        });
    </script>
}
